public class Main {
        public static void main(String[] args) {
            MyTask mt  = new MyTask();

            Thread t1 = new Thread(mt);
            Thread t2 = new Thread(mt);
            Thread t3 = new Thread(mt);

            // 设置线程优先级
            t1.setPriority(Thread.MIN_PRIORITY);
            t2.setPriority(Thread.MAX_PRIORITY);
            t3.setPriority(Thread.NORM_PRIORITY + 2); // 优先级5，默认是5，这里设置为7

            t1.start();
            t2.start();
            t3.start();
        }
    }
    class MyTask implements Runnable {
        @Override
        public void run() {
            for (int i = 0; i < 1100; i++) {
                System.out.println(i);
                try {
                    Thread.sleep(300); // 让线程睡眠300毫秒
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }